package nacos

import (
	"fmt"
	"github.com/nacos-group/nacos-sdk-go/v2/vo"
)

// 获取 ip 端口号
func FindService(service, group_name string) (string, error) {
	client, err := getNamingClient()
	if err != nil {
		return "", err
	}
	getService, err := client.GetService(vo.GetServiceParam{
		ServiceName: service,
		GroupName:   group_name,
	})
	if err != nil {
		return "", err
	}
	return fmt.Sprintf("%s:%d", getService.Hosts[0].Ip, getService.Hosts[0].Port), err
}
